package com.itheima.dao.store;

import com.itheima.domain.store.Catalog;
import com.itheima.domain.store.Course;
import com.itheima.domain.store.Question;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * CatalogMapper
 * 2021/10/16 20:45
 * created by yangyawen
 */
public interface CatalogMapper {
    // 查询所有Catalog
    @Select("select * from st_catalog")
    List<Catalog> findAll();

    // 添加Catalog
    @Insert("insert into st_catalog (id,course_id,name,state,remark,course_name) values (#{id},#{courseId},#{name},#{state},#{remark},#{courseName})")
    void addCatalog(Catalog catalog);

    // 修改Catalog
    @Update("update st_catalog set name=#{name},remark=#{remark},course_name=#{courseName},state=#{state} where id=#{id}")
    void updateCatalog(Catalog catalog);

    // 删除Catalog
    @Delete("delete from st_catalog where id=#{id}")
    void deleteCatalog(@Param("id") String id);

    // 通过id查询Catalog
    @Select("select * from st_catalog where id=#{id}")
    Catalog findCatalogById(@Param("id") String id);


    //通过catalogId查询题目表里面与类型表关联了多少条数据
    @Select("select * from st_question where catalog_id=#{catalogId}")
   List<Question> findQuestionAndCatalog(@Param("catalogId") String catalogId);


}
